package com.mall.coupon.controller;

import cn.hutool.core.bean.BeanUtil;
import com.mall.common.annotation.LogOperation;
import com.mall.common.dto.MemberPriceDTO;
import com.mall.common.dto.SkuReductionDTO;
import com.mall.common.utils.Result;
import com.mall.common.validator.ValidatorUtils;
import com.mall.common.validator.group.AddGroup;
import com.mall.common.validator.group.DefaultGroup;
import com.mall.coupon.dto.SpuBoundsDTO;
import com.mall.coupon.entity.SkuFullReductionEntity;
import com.mall.coupon.entity.SkuLadderEntity;
import com.mall.coupon.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: 谢君臣
 * @Date: 2022/7/25-16:28
 * @version: 1.0
 * @function:
 */
@RestController
@RequestMapping("coupon/feign")
@Api(tags="服务间调用控制器")
public class FeignController {

    @Resource
    private SpuBoundsService spuBoundsService;
    @Resource
    private FeignService feignService;

    @PostMapping("/spubounds/save")
    @ApiOperation("保存积分")
    @LogOperation("保存积分")
    public Result saveSpuBounds(@RequestBody SpuBoundsDTO dto){
        //效验数据
        ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);

        spuBoundsService.save(dto);

        return new Result();
    }


    @PostMapping("/skureduction/save")
    @ApiOperation("保存折扣")
    @LogOperation("保存折扣")
    public Result saveSkuReduction(@RequestBody SkuReductionDTO skuReductionDTO){
        //效验数据
        ValidatorUtils.validateEntity(skuReductionDTO, AddGroup.class, DefaultGroup.class);
        feignService.saveSkuReduction(skuReductionDTO);

        return new Result();
    }

}
